const container = document.querySelector("#container");
const canvas = document.querySelector("#canvas");

const container_size = container.getBoundingClientRect();

canvas.width = container_size.width;
canvas.height = container_size.height;

const context = canvas.getContext("2d");

/**
 * @function 绘制一个充满画布的矩形。
 * @param context2d {CanvasRenderingContext2D}
 * @param color {string} 填充的颜色。
 */
function fillCanvas(context2d, color) {
    context2d.fillStyle = color;
    context2d.fillRect(0, 0, canvas.width, canvas.height);
}

/**
 * @function 在某个区域显示文字。
 * @param x
 * @param y
 * @param color
 * @param text {Array} 想要显示的文字。
 */
function showWindow(x, y, color, text) {
    context.fillStyle = color;
    context.font = "10px 黑体";
    context.save();
    context.translate(x, y);
    for (let i = 0; i < text.length; i++) {
        context.fillText(text[i], 0, 15 * i);
    }
    context.restore();
}
